package com.atguigu.exam;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 5. 如何调用方法show()
 类声明如下：
 package com.atguigu.java;
 class User{
 public void show(){
 System.out.println(“我是一个中国人！”);
 }  }
 * @author xbd
 * @create 2021-06-01 17:19
 */
public class ShowTest {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException {
        Class<User> userClass = User.class;
        User user = userClass.newInstance();
        Method show = userClass.getMethod("show");
        show.setAccessible(true);
        show.invoke(user);
    }
}
